package top.heue.temp.activity.error

import android.view.KeyEvent
import top.heue.temp.databinding.ActivityErrorBinding
import top.heue.utils.base.base.BaseActivity
import top.heue.utils.base.helper.inflate
import top.heue.utils.lifecycle.helper.viewModel

class ErrorActivity : BaseActivity() {
    private val errorModel: ErrorModel by viewModel()
    private val bind: ActivityErrorBinding by inflate {
        error = errorModel
        toolbar.setOnMenuItemClickListener(errorModel.menuOnclick)
    }

    override fun onCreate() {
        super.onCreate()
        setContentView(bind.root)
        errorModel.init(this)
    }

    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            errorModel.restart()
            return true
        }
        return super.onKeyDown(keyCode, event)
    }
}